﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using BaseEntities;
using DataAccess;

namespace BussinessLogic
{
    public class AccountBus
    {
        AccountDAO AccDAO = new AccountDAO();
        public bool UpdateBalanceAccountTransfer(decimal amount, string cardno)
        {
            bool flag;
            try
            {
                SqlParameter param1 = new SqlParameter("@CardNo", cardno);
                SqlParameter param2 = new SqlParameter("@Amount", amount);
                AccDAO.UpdateData("SP_UpdateAccountTransfer", param1, param2);
                flag = true;
            }
            catch (Exception)
            {

                flag = false;
            }
            return flag;

        }
        public bool UpdateBalanceAccountReceive(decimal amount, string cardno)
        {
            bool flag;
            try
            {
                SqlParameter param1 = new SqlParameter("@CardNo", cardno);
                SqlParameter param2 = new SqlParameter("@Amount", amount);
                AccDAO.UpdateData("SP_UpdateAccountReceive", param1, param2);
                flag = true;
            }
            catch (Exception)
            {

                flag = false;
            }
            return flag;
        }
        //public void getbalance(string cardno)
        //{
        //    SqlParameter param1 = new SqlParameter("@CardNo", cardno);
        //    dao.updatedata("SP_GetBalanceAccout", param1);
        //}
        public bool CheckBalance(decimal amount, string cardno)
        {
            if (AccDAO.GetBalance(cardno) > amount)
            {
                return true;
            }
            else
                return false;
        }
    }
}
